package com.yanqu.road.server.manger.activity.recycle;

import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.entity.activity.ActivityItemRecycleData;
import com.yanqu.road.entity.activity.jiuzhou.config.JiuZhouConfig;
import com.yanqu.road.entity.enums.eActivityType;
import com.yanqu.road.entity.player.UserBagItem;
import com.yanqu.road.server.manger.activity.ActivityMgr;
import com.yanqu.road.server.manger.activity.jiuzhou.JiuZhouMgr;

public class JiuZhouRecycleStrategy extends AbstractItemRecycleStrategy {
    @Override
    public void markNeedRecycleItem() {
        JiuZhouConfig config = JiuZhouMgr.getConfig();
        if (config != null && config.getActivityInfo() != null) {
            long recycleTime = config.getActivityInfo().getEndShowTime() * 1000 + 600 * 1000;
            ActivityItemRecycleMgr.addRecycleItemData(config.getMoneyItemId3(), activityType, recycleTime);
        }
    }
    @Override
    public boolean isActivityRunning() {
        JiuZhouConfig config = JiuZhouMgr.getConfig();
        if (config != null && config.getActivityInfo() != null) {
            ActivityInfo activityInfo = config.getActivityInfo();
            return ActivityMgr.activityInTime(activityInfo);
        }
        return false;
    }

    @Override
    protected void initActivityType() {
        activityType = eActivityType.JiuZhou.getValue();
    }

    @Override
    protected void doRecycle(long userId, ActivityItemRecycleData data) {
        int itemId = data.getItemId();
        UserBagItem userBagItem = getUserBagItem(userId, itemId);
        if (userBagItem != null && userBagItem.getNum() > 0) {
            removeItem(userBagItem);
        }
    }
}
